package com.wn.controller;

import com.wn.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author yellow Docter
 * @date 2022 -07-11
 * @desc
 */
@Controller
public class JsonController {

    /**
     * RequestBody  把json对象转成指定的List<String>
     * RequestBody  把json对象转成指定的User
     * @param favs
     * @return
     */
    @ResponseBody  // 返回字符串
    @RequestMapping("/json1")
    public String json1(@RequestBody List<String> favs){

        System.out.println("Arrays.tops = " + favs);

        return "success";

    }

    @ResponseBody  // 返回字符串
    @RequestMapping("/json2")
    public String json2(@RequestBody User user){

        System.out.println("user = " + user);

        return "success";

    }


    @ResponseBody  // 返回字符串
    @RequestMapping("/json3")
    public String json3(@RequestBody List<User> users){

        System.out.println("users = " + users);

        return "success";

    }
}
